#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;


pair<int, int>  cal(vector<int> &num)
{
        int n = num.size();
        vector<int> dp(n, 1);
        vector<int> up(n, 1);

        for(int i = 1; i < n; i++){
                for(int j = 0; j < i; j++){
                        if(num[i] <= num[j]){
                                dp[i] = max(dp[i], dp[j] + 1);
                        }
                        if(num[i] > num[j]){
                                up[i] = max(up[i], up[j] + 1);
                        }
                }
        }

        return {*max_element(dp.begin(), dp.end()), *max_element(up.begin(), up.end())};
}

int main()
{
        // char buf[8*100000];
        // cin.getline(buf, sizeof(buf));
        // istringstream   iss(buf);
        vector<int> num;
        
        int x;
        while(cin >> x){
                num.push_back(x);
        }

        auto result = cal(num);
        cout << result.first << endl;
        cout << result.second << endl;

        return 0;
}